package com.wc.alorithm_luogu.P1321;


import java.util.Scanner;

/**
 * @Author congge
 * @Date 2023/4/23 14:22
 * @description https://www.luogu.com.cn/problem/P1321
 * 单词覆盖还原
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String sentence = sc.nextLine();

        // 存储前一个字母

        String boy = "boy";

        String girl = "girl";

        int boyNum;
        int girlNum;
        // 拆分的长度
        int boyCapacity = (boy.length() + 1) * boy.length() / 2;
        // 存储拆分过后的所有
        String[] compareBoy = new String[boyCapacity];
        int girlCapacity = (girl.length() + 1) * girl.length() / 2;
        // 存储拆分过后的所有
        String[] compareGirl = new String[girlCapacity];
        int boyN = boy.length();
        int index = 0;

        splitWord(boy, compareBoy, boyN, index, boyN);
        int girlN = girl.length();

        index = 0;
        splitWord(girl, compareGirl, girlN, index, girlN);

        // 统计计算
        boyNum = sum(sentence, compareBoy, boyCapacity);
        girlNum = sum(sentence, compareGirl, girlCapacity);
        System.out.println(boyNum);
        System.out.println(girlNum);

    }

    /**
     * 统计数目
     */
    private static int sum(String sentence, String[] compareWord, int compareWordLength) {
        int wordNum = 0;
        int index;
        for (int i = 0; i < compareWordLength; i++) {
            index = sentence.indexOf(compareWord[i]);
            while (index != -1) {
                wordNum++;
                index = sentence.indexOf(compareWord[i], index + 1);
            }
            // 将原来的替换成.
            sentence = sentence.replace(compareWord[i], ".");
        }
        return wordNum;
    }

    /**
     * 拆分单词
     *
     * @param word            将boy 拆分成 boy bo oy b o y
     * @param splitWord       存放拆分的单词
     * @param splitWordLength 拆分的长度
     * @param girlN           原本word 的长度
     */
    private static void splitWord(String word, String[] splitWord, int splitWordLength, int index, int girlN) {
        for (int i = 0; i < girlN; i++) {
            int left = 0;
            int right = girlN - i;
            while (left <= right && right <= splitWordLength) {
                splitWord[index++] = word.substring(left, right);
                left++;
                right++;
            }
        }
    }
}
